<?php ob_start(); ?>
<style>
    .title-body-content {
        color: #A0002A;
        font-size: 17px;
        font-weight: bold;
        height: auto;
        margin: 0 0 0;
        padding: 0;
        text-align: center;
        width: 100%;
    }
    .clearfix:after {
        clear: both;
        content: ".";
        display: block;
        font-size: 0;
        height: 0;
        visibility: hidden;
    }
    .wrapper-content-body {
        background-color: White;
        height: auto;
        margin: 0 0 60px;
        padding: 0 16px 0;
        width: 96.8%;
    }
    .wrapper-form-account-resume {
        height: auto;
        margin: 20px 60px 0;
        text-align: left;
        width: auto;
    }
    .wrapper-insurance-type-page4 {
        margin: 3px 0 0;
    }
    .clearfix {
        display: block;
    }
    .wrapper-rein-page4 {
        margin: 3px 0 0;
    }
    .wrapper-insurance-type-page4 {
        margin: 3px 0 0;
    }
    .wrapper-ori-insurer-page4 {
        margin: 3px 0 0;
    }
    .wrapper-rate-page4 {
        margin: 3px 0 0;
    }
    .wrapper-gross-pre-page4 {
        margin: 3px 0 0;
    }
    .wrapper-rate-page4 {
        margin: 3px 0 0;
    }
    .wrapper-gross-pre-page4 {
        margin: 3px 0 0;
    }
    .wrapper-gross-pre-page4 {
        margin: 3px 0 0;
    }
    .wrapper-payment-schedule {
        height: auto;
        margin: 20px 0 0;
        width: auto;
    }
    .size-span {
        display: inline-block;
        vertical-align: top;
        width: 135px;
    }
    .tbl-payment {
        height: auto;
        margin: 20px 0;
        table-layout: fixed;
        width: 98.6%;
    }
    .wrapper-payment-schedule {
        height: auto;
        margin: 20px 0 0;
        width: auto;
    }
    .wrapper-content-payment-schedule {
        height: auto;
        width: auto;
    }
    .tbl-payment tr {
        height: auto;
        padding: 5px;
    }
    .tbl-payment-title {
        font-weight: bold;
    }
    .tbl-payment tr td {
        height: auto;
        padding: 5px;
    }
</style>
<div class="header clearfix">
    <div class="head-logo">
        <?php echo $this->Html->image('/img/aih/ARBL FULL Logo Letterhead Footer JPG r.jpg'); ?>
    </div>
    <!-- HTML for menu-bottom-header-->
</div>
<!-- HTML-Body-Web-->
<div class="wrapper-body clearfix">
    <div class="wrapper-content-body clearfix">
        <div class="" style="text-align:right; padding-right:220px; margin:10px 0"><b>Dated <?php echo date('jS M Y', strtotime($this->request->data['Accountresume']['date'])); ?></b></div>
        <div class="title-body-content"><?php echo $title_for_layout; ?> <?php echo $this->request->data['Accountresume']['refid_edit']; ?></div>
        <div class="wrapper-form-account-resume clearfix">
            <div class="wrapper-insurance-type-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Type'); ?> :</b></span>
                <?php echo $insurancetype['Insurancetype']['name']; ?>
            </div>
            <div class="wrapper-rein-page4 clearfix">
                <table cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td style="text-align:left; vertical-align:top">
                            <span class="size-span" style="width:200px"><b><?php echo __('Reinsured'); ?> :</b></span>
                        </td>
                        <td style="text-align:left">
                            <?php
                            echo '<div class="contactField" style="text-align:left">';
                            echo '   <span class="size-span" style="width: 260px; float:left">';
                            echo '       <b>' . $this->request->data['Accountresume']['reinsured'] . '</b>';
                            echo '   </span>';
                            echo '</div>';
                            ?>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="wrapper-ori-insurer-page4 clearfix">
                <table cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td style="text-align:left; vertical-align:top">
                            <span class="size-span" style="width:200px"><b><?php echo __('Original Insured'); ?> :</b></span>
                        </td>
                        <td style="text-align:left">
                            <?php
                            echo '<div class="contactField" style="text-align:left">';
                            echo '   <span class="size-span" style="width: 260px; float:left">';
                            echo '       <b>' . $this->request->data['Accountresume']['original_insured'] . '</b>';
                            echo '   </span>';
                            echo '</div>';
                            ?>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="wrapper-insurance-type-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Period of cover'); ?> :</b></span>
                <b>From <?php echo date('jS M Y', strtotime($this->request->data['Accountresume']['from_date'])); ?> to <?php echo date('jS M Y', strtotime($this->request->data['Accountresume']['to_date'])); ?></b>
                (<?php echo $this->request->data['Accountresume']['total_days']; ?> days)
            </div>
            <div class="wrapper-sum-insured-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Sum Insured / agreed value'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['currency']; ?> <?php echo number_format($this->request->data['Accountresume']['sum_insured'], 2); ?></b>
            </div>
            <div class="wrapper-rate-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Rate'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['rate']; ?> %</b>
            </div>
            <div class="wrapper-gross-pre-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('100% Gross Premium'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['currency']; ?> <?php echo number_format($this->request->data['Accountresume']['gross_premium'], 2); ?></b>
            </div>
            <div class="wrapper-rate-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Order Hereon'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['order_hereon']; ?> %</b>
            </div>
            <div class="wrapper-gross-pre-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Nett Premium'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['currency']; ?> <?php echo number_format($this->request->data['Accountresume']['nett_premium'], 2); ?></b>
            </div>
            <div class="wrapper-gross-pre-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Client Discount'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['client_discount']; ?> %</b>
            </div>
            <div class="wrapper-gross-pre-page4 clearfix">
                <span class="size-span" style="width:200px"><b><?php echo __('Order Premium'); ?> :</b></span>
                <b><?php echo $this->request->data['Accountresume']['currency']; ?> <?php echo number_format($this->request->data['Accountresume']['order_premium'], 2); ?></b>
            </div>
            <?php
            $payable_froms = array();
            // repair
            foreach ($paymentschedules as $paymentschedule) {
                $payable_froms[$paymentschedule['Paymentschedule']['payer']][] = $paymentschedule;
            }
            foreach ($payable_froms as $payable_from) {
                $html_payable_froms = '';
                $html_payment_schedule_infos = '
            <div class="wrapper-payment-schedule clearfix" style="margin-top:0">
                <div class="wrapper-content-payment-schedule clearfix">
                    <table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:0" class="tbl-payment">';
                foreach ($payable_from as $v) {
                    $html_payable_froms = '
                <div class="wrapper-gross-pre-page4 clearfix">
                    <span class="size-span" style="width:800px"><b>' . __('Premium Payable from') . ' ' . $v['Paymentschedule']['payer_name'] . '</b></span>
                </div>';
                    $html_payment_schedule_infos .= '
                        <tr class="tbl-payment-title striped">
                            <td class="td-from-producing-broker" width="360" style="text-align:left">
                                <b>' .
                            round($v['Paymentschedule']['broker_amount'] / $this->request->data['Accountresume']['nett_premium'], 2) * 100 .
                            '% on or before ' .
                            date('jS M Y', strtotime($v['Paymentschedule']['broker_date'])) .
                            '</b>
                            </td>
                            <td class="td-to-asurasi" style="text-align:left">
                                <b>' .
                            $v['Paymentschedule']['currency'] . ' ' . number_format($v['Paymentschedule']['broker_amount'], 2) .
                            '</b>
                            </td>
                        </tr>';
                }
                $html_payment_schedule_infos .= '
                    </table>
                </div>
            </div>';
                echo $html_payable_froms, $html_payment_schedule_infos;
            }
            ?>
            <div class="wrapper-payment-schedule clearfix">
                <div class="wrapper-content-payment-schedule clearfix">
                    <table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:0" class="tbl-payment">
                        <tr class="tbl-payment-title striped">
                            <td class="td-from-producing-broker" width="360" style="text-align:left; font-weight:normal;">
                                
                            </td>
                            <td class="td-to-asurasi" style="text-align:left"></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="wrapper-payment-schedule clearfix" style="border:1px solid #DFDDDD; padding-left: 20px">
                <div class="wrapper-content-payment-schedule clearfix">
                    <table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:0" class="tbl-payment">
                        <tr class="tbl-payment-title striped">
                            <td class="td-from-producing-broker" width="360" style="text-align:left;">
                                THE ABOVEMENTIONED PREMIUM SHALL BE PAID IN FAVOUR OF<br />
                                <br />
                                <?php
                                    echo $aihcontact['Aihcontact']['name'] . '<br />';
                                    echo $aihcontact['Aihcontact']['address'] . '<br /><br />';
                                    
                                    echo 'Bank details: (for '. $bank1['Bank']['currency_name'].' payments) <br />';
                                    echo 'Beneficiary: ' . $bank1['Bank']['bank_account_name'] . '<br />';
                                    echo 'Bank: ' . $bank1['Bank']['name'] . '<br />';
                                    echo $bank1['Bank']['address'] . '<br />';
                                    echo 'SWIFT Code: ' . $bank1['Bank']['swift_code'] . '<br /><br />';
                                    
                                    if($bank12!=null) {
                                        echo 'Bank details: (for '. $bank12['Bank']['currency_name'].' payments) <br />';
                                        echo 'Beneficiary: ' . $bank12['Bank']['bank_account_name'] . '<br />';
                                        echo 'Bank: ' . $bank12['Bank']['name'] . '<br />';
                                        echo $bank12['Bank']['address'] . '<br />';
                                        echo 'SWIFT Code: ' . $bank12['Bank']['swift_code'] . '<br /><br />';
                                    }
                                    echo 'Correspondent Bank: <br />';
                                    echo $bank2['Bank']['name'] . '<br />';
                                    echo $bank2['Bank']['address'] . '<br />';
                                    echo 'SWIFT Code: ' . $bank2['Bank']['swift_code'] . '<br /><br />';
                                    echo 'Correspondent Bank Account: ' . $bank2['Bank']['account'] . '<br />';
                                ?>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <?php
    $HtmlCode = ob_get_contents();
    ob_end_flush();
    $HtmlCode1 = str_replace('/aih/img/aih/ARBL FULL Logo Letterhead Footer JPG r.jpg', 'img/ARBL FULL Logo Letterhead Footer JPG r.jpg', $HtmlCode);
    $file = '/home/johnso28/public_html/aihreinsurance.com/dompdf/aih/debit_note.html';
    file_put_contents($file, $HtmlCode1);
    ?>
    <div class="wrapper-button-form clearfix">
        <div class="button-form clearfix">
            <a href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/dompdf/dompdf.php?base_path=aih/&input_file=debit_note.html&paper=a4">Download PDF</a>
        </div>
    </div>
</div>